package it.polimi.traveldream.beans;

import it.polimi.traveldream.dto.ActivityDTO;
import it.polimi.traveldream.ejb.ProductManager;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = "activityBean")
@RequestScoped
public class ActivityBean {

	@EJB
	private ProductManager productManager;

	private ActivityDTO activity;

	public ActivityBean() {
		this.activity = new ActivityDTO();
	}

	public ActivityDTO getActivity() {
		return this.activity;
	}

	public void setActivity(ActivityDTO activity) {
		this.activity = activity;
	}

	public String save() {
		this.productManager.save(this.activity);
		return "/employee/products/list?faces-redirect=true";
	}

	public List<ActivityDTO> getActivities() {
		return this.productManager.getActivities();
	}

	public List<ActivityDTO> getFiltered(String city) {
		return this.productManager.getActivity(city);
	}

	public String removeActivity(ActivityDTO a) {
		this.productManager.removeActivity(a);
		return "?faces-redirect=true";
	}
}
